package com.sport.mapper;

import com.github.pagehelper.Page;
import com.sport.entity.SysMenu;
import com.sport.entity.SysPermission;
import com.sport.entity.SysRole;
import com.sport.entity.SysUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface SysUserMapper {
  //根据用户名获取用户对象
    SysUser findByUsername(String username);

    List<SysRole> findRoles(@Param("userId") Integer userId);

    List<SysMenu> findMenus(@Param("userId") Integer userId);

    List<SysPermission> findPermissions(@Param("userId") Integer userId);
//父级的Id
//  根据父级Id和子级Id查询子菜单
    List<SysMenu> findChildrenMenu(@Param("id") Integer id,@Param("userId") Integer userId);

    List<SysMenu> userfindMenus();



//    分页查询用户信息
    Page<SysUser> findPage(String queryString);

void insert(SysUser user);
    void delete(long id);
    void update(SysUser user);

    void insertUserRole(@Param("userId") long userId,@Param("roleId") long roleId);

    void deleteRolesByUserId(@Param("userId") long userId);

    SysUser findById(long id);

    @Update("update sys_user set `password`=#{password} where email=#{email}")
    void updatePwdByMail(@Param("email") String email, @Param("password") String password);

}

